﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>活动报名</title>
     <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no" />
    <link href="../Frozenui1.3/css/frozen.css" rel="stylesheet" />
    <script src="../JS/layer/layer.m.js"></script>
    <script src="../JS/zepto.min.js"></script>
    <script src="../Frozenui1.3/js/frozen.js"></script>
    <script src="/Scripts/avalon.js"></script>
    <script src="/Scripts/SZHLCommon.js"></script>
    <script src="../JS/MobileCom.js?v=1.1"></script>
    <script>
        var strId = ComFunJS.getQueryString("ID");
        var hdinfo = avalon.define({
            $id: "hdinfo",
            modelData: {},
            num: 0,
            status: "未报名",
            plData: {},
            plcount: 0,
            bmData: { "HDID":strId,"BMLxr": "", "BMLxDH": "", "BMCount": "" },
            bmcj: function () {
                
                var tc = layer.open({
                    type:1,
                    //content:$("#bmxx").html(),
                    title:"报名信息",
                    content: '<div class="ui-form ui-border-t" ><div class="ui-form-item ui-border-b"><label>联系人</label><input type="text" placeholder="请输入联系人" id="lxr" value="' + hdinfo.bmData.BMLxr + '" /></div><div class="ui-form-item ui-border-b"><label>联系人手机</label><input type="text" placeholder="请输入联系人手机" id="lxrsj" value="' + hdinfo.bmData.BMLxDH + '" /></div><div class="ui-form-item ui-border-b"><label>报名人数</label><input type="text" placeholder="请输入报名人数" id="bmrs" value="' + hdinfo.bmData.BMCount + '" /></div></div>',
                    btn: ['确认', '取消'],
                    shadeClose: false,
                    yes: function () {
                        hdinfo.bmData.BMCount = $("#bmrs").val();
                        hdinfo.bmData.BMLxDH = $("#lxrsj").val();
                        hdinfo.bmData.BMLxr = $("#lxr").val();

                        layer.close(tc);

                        var lg = $.loading({
                            content: '保存中...',
                        })

                        $.getJSON('/API/WXAPI.ashx?Action=ADDHDBMITEM&r=' + Math.random(), { P1: JSON.stringify(hdinfo.bmData.$model) }, function (resultData) {
                            lg.hide();
                            if (resultData.ErrorMsg == "") {
                                $("#bmcj").hide();
                                var el=$.tips({
                                    content: "保存成功",
                                    stayTime: 2000,
                                    type: "success"
                                })
                                el.on("tips:hide", function () {
                                    window.location.reload();
                                })
                            }
                            else {
                                $.tips({
                                    content: "保存失败，原因：" + resultData.ErrorMsg,
                                    stayTime: 2000,
                                    type: "warn"
                                })
                            }
                            
                        })
                    }, no: function () {
                    }
                })
            },
            scpl: function (plel) {
                var tc = layer.open({
                    content: '确定要删除此评论吗？',
                    btn: ['确定', '取消'],
                    shadeClose: false,
                    yes: function () {
                        layer.close(tc);
                        var lg = $.loading({
                            content: '删除中...',
                        })
                        $.getJSON('/API/WXAPI.ashx?Action=DELTL&r=' + Math.random(), { P1: plel.ID }, function (resultData) {
                            lg.hide();
                            if (resultData.ErrorMsg == "") {
                                hdinfo.plData.remove(plel);
                                hdinfo.plcount = hdinfo.plcount - 1;
                                var el = $.tips({
                                    content: "删除成功",
                                    stayTime: 2000,
                                    type: "success"
                                })
                                el.on("tips:hide", function () {
                                    //window.location.reload();
                                })
                            }
                            else {
                                $.tips({
                                    content: "删除失败，原因：" + resultData.ErrorMsg,
                                    stayTime: 2000,
                                    type: "warn"
                                })
                            }
                        })
                    }, no: function () {
                    }
                })
            }
        });
        avalon.ready(function () {
            if (strId != null) {
                var lg = $.loading({
                    content: '加载中...',
                })
                $.getJSON('/API/WXAPI.ashx?Action=GETUSERHDBMLIST&Id=' + strId + '&r=' + Math.random(), {}, function (resultData) {
                    lg.hide();
                    if (resultData.ErrorMsg == "") {
                        hdinfo.modelData = resultData.Result[0]; 
                        hdinfo.plData = resultData.Result[0].PLList;
                        hdinfo.plcount = resultData.Result[0].PLList.length;
                        if (!MobileCom.compareDate(resultData.Result[0].HDTime.substring(0,10), ""))
                        {
                            $("#bmcj").show();
                        }
                        var str = resultData.Result[0].itemUser;
                        if (!(str == "" || str == null || str == "null"))
                        {
                            hdinfo.status = "已报名";
                            $("#bmcj").text("已报名");
                            $.getJSON('/API/WXAPI.ashx?Action=GETHDBMITEMBYUSER&r=' + Math.random(), { P1: strId }, function (resultData) {
                                if (resultData.ErrorMsg == "") {
                                    var data = resultData.Result;
                                    hdinfo.bmData = data;
                                }
                            })
                        }
                    }
                })

                $.getJSON('/API/WXAPI.ashx?Action=GETHDBMITEM&r=' + Math.random(), { P1: strId }, function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        var data=resultData.Result;
                        for (var i = 0; i < data.length; i++)
                        {
                            hdinfo.num = hdinfo.num + data[i].BMCount;
                        }
                    }
                })
                $(".ui-btn").click(function () {
                    var lg = $.loading({
                        content: '加载中...',
                    })
                    $.getJSON('/API/WXAPI.ashx?Action=ADDCOMENT&r=' + Math.random(), { "P1": $("#content").val(), "MsgType": "HDBM", "MsgLYID": strId }, function (resultData) {
                        lg.hide();
                        if (resultData.ErrorMsg == "") {
                            hdinfo.plData.push(resultData.Result);
                            hdinfo.plcount = hdinfo.plcount + 1;
                            var el = $.tips({
                                content: "评论成功！！",
                                stayTime: 2000,
                                type: "success"
                            })
                            $("#content").val("");
                        }
                        else {
                            var el = $.tips({
                                content: "评论失败！！",
                                stayTime: 2000,
                                type: "warn"
                            })
                        }
                    })
                });
            }

        })
        function issc(str)
        {
            if (str == MobileCom.getCookie("szhlusername")) {
                return '<div class="ui-badge-corner" style=" position: relative; " ms-click="scpl(el)">删除</div>';
            }
            else {
                return '';
            }
        }
    </script>
    <style>
        .ui-list > li {
            margin: 3px;
            padding-left: 15px;
        }
        .ui-form-item .wspan {
            width: 100%;
            -webkit-box-sizing: border-box;
            box-sizing: border-box;
            -webkit-appearance: none;
            border: 0;
            background: 0 0;
            padding-left: 95px;
        }
        .ms-controller, [ms-controller] {
            display: none;
        }
    </style>

</head>
<body ms-controller="hdinfo">
    <header class="ui-header ui-header-stable ui-border-b">
        <i class="ui-icon-return" onclick="history.back(-1)"></i>
        <h1>活动信息查看</h1>
        <!--<a class="ui-btn ui-btn-primary" ms-href="UI_HDBM_INPUT.html?ID={{modelData.ID}}" style="color:white">编辑</a>-->
    </header>
    <div class="ui-footer ui-footer-stable ui-btn-group ui-border-t">
        <section class="ui-input-wrap ui-border-t" style="width:100%">
            <div class="ui-input ui-border-radius">
                <input id="content" type="text" name="" value="" placeholder="我也说一句...">
            </div>
            <button class="ui-btn">评论</button>
        </section>
    </div>
    <section class="ui-container">
        <div class="ui-form ui-border-t">
            <div class="ui-form-item ui-border-b" style="height:auto">
                <label>
                    发起方
                </label>
                <span class="wspan">{{modelData.HDFQF}}</span>
            </div>
            <div class="ui-form-item ui-border-b">
                <label>
                    活动时间
                </label>
                <span class="wspan">{{modelData.HDTime|date("yyyy-MM-dd")}}</span>
            </div>
            <div class="ui-form-item ui-border-b">
                <label>
                    报名截止
                </label>
                <span class="wspan">{{modelData.HDBMEndTime|date("yyyy-MM-dd")}}</span>
            </div>
            <div class="ui-form-item ui-border-b" style="height:auto">
                <label>
                    活动主题
                </label>
                <span class="wspan">{{modelData.HDTitle}}</span>

            </div>
            <div class="ui-form-item ui-border-b" style="height:auto">
                <label>
                    活动简介
                </label>
                <span class="wspan" ms-html="modelData.HDContent"></span>
            </div>
            <div class="ui-form-item ui-border-b">
                <label>
                    已报名人数
                </label>
                <span class="wspan">{{num}}</span>
            </div>
            <div class="ui-form-item ui-border-b">
                <label>
                    是否报名
                </label>
                <span class="wspan">{{status}}</span>
                <a id="bmcj" class="ui-btn-lg ui-btn-primary" ms-click="bmcj()" style="float: right; display: none;width: auto; height: 30px; line-height: 30px; margin-top: 7px;">报名</a>
            </div>
            <div class="ui-form" style="display:none;">
                <ul class="ui-grid-halve">
                    <li>
                        <div class="ui-grid-halve-img">
                            <span style="background-image:url(http://placeholder.qiniudn.com/290x160)"></span>
                        </div>
                    </li>
                </ul>

            </div>
            <div class="ui-form-item ui-border-b">
                <label>
                    评论区
                </label>
                <span class="wspan">共 {{plcount}} 条评论</span>
            </div>
            <div class="ui-form ui-border-t">
                <ul class="ui-list ui-list-pure">
                    <li class="ui-border ui-label-list" ms-repeat-el="plData">
                        <div style="display: -webkit-box;">
                            <div class="ui-avatar-s">
                                <span style="background-image:url(../img/ava1.png)"></span>
                            </div>
                            <div class="ui-list-info">
                                <h4>{{el.CRUserName}}</h4>
                            </div>
                            <div class="ui-list-info">
                                <p>{{el.CRDate|date("yyyy-MM-dd HH:mm")}}</p>
                            </div>
                            <!--{{issc(el.CRUser)|html }}-->
                            
                        </div>
                        <p class="ui-txt-justify" ms-html="el.MSGContent"></p>
                    </li>
                </ul>
            </div>
        </div>
        

</section>
</body>
</html>
